<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<meta name="viewport"
	      content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
	<meta http-equiv="X-UA-Compatible" content="ie=edge">
	<title>全国青少年电子信息智能创新大赛</title>
	<link rel="icon" href="./images/logo.png">
	<link rel="stylesheet" href="./lib/swiper/css/swiper.min.css">
	<link rel="stylesheet" href="./lib/layui/css/layui.css">
	<link rel="stylesheet" href="./css/personal.css">
	<link rel="stylesheet" href="./lib/layui/css/modules/layer/default/layer.css">
	<script src="./lib/layui/layui.js"></script>
	<script src="./lib/layui/lay/modules/layer.js"></script>
</head>
<body>
<section class="wrapper" v-cloak>
	<common-header></common-header>
	<section class="banner" style="background-image: url(./images/about-banner.png);">
	</section>
	<section class="content">
		<section class="container">
			<user-tabs active-path="message.html"></user-tabs>
			<section class="tab-content">
				<section class="title">消息中心</section>
				<section class="details">
					<section v-if="messageList.length > 0">
						<section class="game-list" v-for="item in messageList">
							<section class="game-item">
								<section class="text">
									<section class="name"><span v-if="item.cstring=='√'" style="color:green">√</span>
                        <span v-else-if="item.cstring=='X'" style="color:red">X</span>
												<span v-else style="color:red"></span>
										{{ item.title }}</section>
									<section class="time">{{ item.createTime }}</section>
								</section>
								<a :href="'./notice-details.html?isNotice=true&id=' + item.id">查看详情</a>
							</section>
						</section>
					</section>
					<Empty v-else text="还没消息哦"></Empty>
				</section>
				<section id="page"></section>
			</section>
		</section>
	</section>
	<common-footer></common-footer>
</section>
<script src="./lib/swiper/js/swiper.min.js"></script>
<script src="./js/jquery.min.js"></script>
<script src="./lib/layui/layui.js"></script>
<script src="../js/abkj/slAjax.js"></script>
<script src="../js/abkj/match/api/webinfo.js"></script>
<script src="../js/abkj/match/api/news.js"></script>
<script src="../js/abkj/ext/news.js"></script>
<script src="../js/abkj/ext/questionExt.js"></script>
<script src="../js/abkj/fun_tool.js"></script>
<script src="./js/vue.min.js"></script>
<script src="./js/common.js"></script>
<script src="./components/index.js"></script>

<script>
	$(function () {
		var vm = new Vue({
			el: '.wrapper',
			data: {
				currTab: 1,
				page: 1,
				total: 0,
				laypage: null,
				messageList: []
			},
			mounted: function () {
				this.getData()
			},
			methods: {
				getData: function () {
					var vm = this
					var varFun = fun_tool()
					NewsPageList(
						{
							page: {current: this.page, size: 10}, cond: {
								eq: {
									userId: varFun.getUserInfo().id
								},
								in: {attrName: 'model_name', data: ['组队消息', '用户消息']},
								order:{
									attrName:['create_time'],
									type:'desc'
								}
							}
						},
						function (data) {
							var list=[]
							for (i=0;i<data.records.length;i++){
								  var content=data.records[i].content
									var json={}
									if (content.indexOf("已通过审核")>-1){
                      json.cstring='√'
											json.id=data.records[i].id
											json.title=data.records[i].title
											json.createTime=data.records[i].createTime
									}
									else if (content.indexOf("未通过审核")>-1){
										json.cstring='X'
										json.title=data.records[i].title
										json.id=data.records[i].id
										json.createTime=data.records[i].createTime

									}
									else {
										json.cstring=''
										json.title=data.records[i].title
										json.id=data.records[i].id
										json.createTime=data.records[i].createTime

									}
									list.push(json)
							}
							vm.messageList = list
							vm.total = list.length
							if (!layui.laypage) {
								layui.use(['laypage'], function () {
									layui.laypage.render({
										elem: 'page',
										count: vm.total,
										limit: 10,
										jump: function (obj, first) {
											if (first) return
											vm.page = obj.curr
											vm.getData()
										}
									})
								})
							}
						},
						function (err) {
							console.log(err)
						})
				}
			}
		})
	})
</script>
</body>
</html>
